/*
  This file is part of JCM.

  JCM is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  JCM is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with JCM.  If not, see <http://www.gnu.org/licenses/>.
*/
/** Classe cronômetro com granularidade segundos. */
public class Chrono
{
  /** Instante inicial de cronometragem. */
  private long t0;

  /** Instante final de cronometragem. */
  private long t1;

  public Chrono() {}

  /** Inicia a cronometragem. */
  public void start() { t0 = System.nanoTime(); }

  /** Encerra a cronometragem. */
  public void stop() { t1 = System.nanoTime(); }

  /**
   * Retorna o número de segundos entre o instante inicial e final.
   *
   * @return O tempo decorrido entre o instante inicial e final em segundos.
  */
  public double time() { return (t1 - t0) / NANO; }

  /** Número de nano-segundos num segundo. */
  public final double NANO = 1e9;
}